/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * <p>Project: jse2302 - Exce2
 * <p>Powered by webrx On 2023-06-21 16:31:46
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Exce2 {
    public static void main(String[] args) {
        int a = 0;
        int b = 0;
        int c = 0;
        Scanner sc = new Scanner(System.in);
        while (true) {
            try {
                System.out.print("请输入a:");
                a = sc.nextInt();
                while(true) {
                    System.out.print("请输入b:");
                    try{
                        b = sc.nextInt();
                        if(b == 0){
                            System.out.println("不能输入0");
                            continue;
                        }
                        break;
                    }catch(Exception e){
                        System.out.println("输入错误：必须是数字");
                        sc.next();
                    }

                }
                c = a / b;
                System.out.printf("%d / %d = %d", a, b, c);
                break;
            } catch (InputMismatchException e) {
                System.out.println("输入错误：必须是数字");
                sc.next();
                //String str = sc.next();
                //if("exit".equalsIgnoreCase(str)){
                //    //System.exit(0);
                //    break;
                //}
            } catch (ArithmeticException e) {
                System.out.println("第二个数输入错误，不能为0");

            } catch (Exception e) {
                System.out.println("程序未知错误");
                sc.next();
            }

        }
    }
}
